﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicCommon;
using T_vehicle.Domain;
using T_vehicle.Infrastructure.Interfacec;
using T_vehicle.Read.API.Application.Command.AccidentCommand;
using T_vehicle.Read.API.Application.Command.ExpensesCommand;
using T_vehicle.Read.API.Application.Command.IllegalCommand;
using T_vehicle.Read.API.Application.Command.MaintenanceCommand;
using T_vehicle.Read.API.Application.Command.RepairRecordsCommand;
using T_vehicle.Read.API.Application.Command.TiresUsedCommand;

namespace T_vehicle.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class IRepairRecordsController : ControllerBase
    {
        private readonly IMediator mediator;

        public IRepairRecordsController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 显示维修记录信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpGet]   
        public async Task<PageResult<RepairRecords>> GetRepairRecords([FromQuery]GetRepairRecordsCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 反填维修记录信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpGet]
        public async Task<RepairRecords> FanRepairRecords([FromQuery] FanRepairRecordsCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 显示保养记录信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpGet]
        public async Task<PageResult<Maintenance>> GetMaintenance([FromQuery] GetMaintenanceCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 反填维修记录信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpGet]
        public async Task<Maintenance> FanMaintenance([FromQuery] FanMaintenanceCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 显示违章记录信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Illegal>> GetIllgal([FromQuery] GetIllgalCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 反填章记录信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Illegal> FanIllgal([FromQuery] FanIllgalCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;                                                                                                                 
            }
        }



        /// <summary>
        /// 显示事故信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Accident>> GetAccident([FromQuery] GetAccidentCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }



        /// <summary>
        /// 反填事故录信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Accident> FanAccident([FromQuery] FanAccidentCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }


        /// <summary>
        /// 显示轮胎使用信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<TiresUsed>> GetTiresUsed([FromQuery] GetTiresUsedCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }


        /// <summary>
        /// 反填轮胎使用信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<TiresUsed> FanTiresUsed([FromQuery] FanTiresUsedCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }




        /// <summary>
        /// 显示新增费用信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Expenses>> GetExpenses([FromQuery] GetExpensesCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }


        /// <summary>
        /// 反填使用费用信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Expenses> FanExpenses([FromQuery] FanExpensesCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
